package hbase;

import com.htdata.iiot.api.hbase.utils.HbaseOperation;
import com.htdata.iiot.api.tsdb.utils.Tools;
import org.junit.Test;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class HbaseT {
    @Test
    public void testQurey(){
        try {
            HbaseOperation.getOneRecord("cs","row1".getBytes());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    @Test
    public void testBatchDel(){
        try {
            HbaseOperation.getOneRecord("cs","row1");
            List<byte[]> list = new ArrayList<>();
            list.add("row1".getBytes());
            list.add("row2".getBytes());
            HbaseOperation.batchDel("cs",list);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    @Test
    public void testAvg(){
        List<Integer> list = new ArrayList<>();
        list.add(1);
        list.add(2);
        list.add(3);
        list.add(4);
        List<Integer>[] rL = Tools.avgList(list, 4);
        List<Integer> rr = rL[0];
        for (int i:rr){
            System.out.println(i);
        }

    }

    @Test
    public void testArray(){
        List<byte[]> list = new ArrayList<>();
        byte[] b = new byte[1];
        b[0] = 1;
        byte[] b1 = new byte[1];
        b1[0] = 2;
        byte[] b2 = new byte[1];
        b2[0] = 3;
        list.add(b);
        list.add(b1);
        list.add(b2);
        List<byte[]> ll = new ArrayList<>();
        for(byte[] v:list){
            System.out.println(Arrays.toString(v));
            ll.add(v);
        }
        for(byte[] v:list){
            System.out.println(Arrays.toString(v));
            ll.add(v);
        }

    }
}
